<?php
class Sources extends Model{
	
	function getActive(){
		$sql ="SELECT * FROM customer_source csr ";
		$query=$this->db->query($sql);
		return $query->result_array();
	}
    
    function getCek(){
        $sql ="SELECT * FROM customer_source csr ";
		$sql.="WHERE csr.source_name = '".$this->input->post('name')."' LIMIT 1";
        $query=$this->db->query($sql);
		return $query->row_array();
    }
    
    function getSave(){
        $value = array  (
                            'source_name'=>  $this->input->post('name'),
                            'user_stamp' =>  $this->session->userdata('user_id'),
                            'date_stamp' =>  date('Y-m-d')
                        );               
        $this->db->insert('customer_source',$value); 
    }
    
    function getUpdate(){
        $value = array  (
                            'source_name'=>  $this->input->post('name'),
                            'user_stamp' =>  $this->session->userdata('user_id'),
                            'date_stamp' =>  date('Y-m-d')
                        );
        $this->db->where('id',$this->input->post('id'));                 
        $this->db->update('customer_source',$value); 
    }
    
    function getRemove(){
        $this->db->where('id',$this->input->post('id'));
        $this->db->delete('customer_source');
    }
}